-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix compilation under cython 3. #41530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -23,6 +23,15 @@ from pandas._libs.util cimport ( | |||
|
|||
from pandas._libs.lib import is_scalar | |||
|
|||
# Accessing the data member of ndarray is deprecated, but we depend on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess this adapts to the letter of the deprecation but not the spirit?
There is more background to this in #34014 where the discussion seems to ideally want to get us out of this modification altogether. Are there any alternatives to this you can think of? |
The assumption here is Cython 3.0 support lands before numpy's removal of data member access. This is very likely the case. To fix the dependency on deprecated of data member access (which becomes orthogonal to cython 3.0 support after this PR, so perhaps we shall start a new issue), either approaches described the bug is viable. Along pathway 1, a quick idea that may work is to rewrite reduction.pyx using cython memoryview objects. The python side (if there is any user to these delegate ndarray objects), we can add an accessor to create ndarrays on the fly. The cython side can swap to operating on memoryview, or some form of customized surrogate that allows resetting the pointer. This way we can do the port without needing to modify / understand too much of the magic inside reduction.pyx. |
is there reason for optimism that cython3 is coming anytime soon?
Option 2 here is much simpler: just create new ndarrays by slicing; the perf penalty isn't all that bad.
it isn't clear to me that this is feasible. we're dealing with User Defined Functions |
On Tue, May 18, 2021 at 10:35 AM jbrockmendel ***@***.***> wrote:
The assumption here is Cython 3.0 support lands before numpy's removal of
data member access. This is very likely the case.
is there reason for optimism that cython3 is coming anytime soon?
I am not a cython maintainer, but it certainly would add to the evidence
3.0 is ready to be out of alpha if it can compile most downstream packages
cleanly.
Along pathway 1, a quick idea that may work is to rewrite reduction.pyx
using cython memoryview objects. The python side (if there is any user to
these delegate ndarray objects), we can add an accessor to create ndarrays
on the fly
Option 2 here
<#34213 (comment)>
is much simpler: just create new ndarrays by slicing; the perf penalty
isn't all that bad.
The cython side can swap to operating on memoryview,
it isn't clear to me that this is feasible. we're dealing with User
Defined Functions
Sorry, I was not familiar with the internals of pandas -- Is there a
Cython/C-API for User Defined Functions, or they must go through python?
… —
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#41530 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABBWTGYF4I4A5FSYOQVNJ3TOKQMLANCNFSM45BLLRQQ>
.
|
Hello @rainwoodman! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-05-19 17:27:36 UTC |
Not sure if the workflow is added correctly. Current list of failures on my local machine:
None of them look relevant to the cython-3 compiler change. |
There is no such API. The |
FWIW I am slightly -1 on this as is. I would prefer we figure out a way to fix now rather than waiting for this to become an issue with a future numpy release |
Thanks @jbrockmendel for the explanation. @WillAyd I have gather enough confidence to take a closer look over modernizing reduction.pyx, picking up from the last attempt with segfaults at #34014. I'll give it a go. |
Is there a way to mutate a cached_index's indices without creating the index? The equivalence to cached_series._mgr.set_values. (I'll keep looking in indexes/base.py, but if someone already know..) If we have that function then we can likely write something along these lines:
This way we avoid the cost of creating cached_index and cached_series, which are likely more expensive than creating a ndarray from a memoryview. |
that's what we're doing when we set |
Thanks. Now I see the example resettting
I am trying to understand how
So it appears that that line of setattr in BlockSlider has no effect on the other states of the Index object; -- or I am missing some code logic that uses _index_data? |
_index_data is basically just an alias for _data at this point; for a while it was used in some Index subclasses but i think those have all been taken out |
After setattr, _index_data and _data diverges to two objects, and they are no longer aliases. So to reset the index (index.set_values), I shall look into a "state-consistent" way of resetting the _data attribute, which is the one actually consumed as an internal state of an |
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
@rainwoodman are you still working on this? |
Thanks for the PR, but it appears this PR has gone stale. It may be easier now that |
Thanks for closing. If by the time I revisit this the issue still persists,
I'll file a new PR. ;)
…On Mon, Aug 16, 2021 at 6:51 PM Matthew Roeschke ***@***.***> wrote:
Closed #41530 <#41530>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41530 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABBWTEAXIZOSLM44PEARQ3T5G6DDANCNFSM45BLLRQQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Internal clean up to improve Cython 3 compatibility.
See #34213.